﻿using System;
using System.Collections.Generic;
using System.Collections.ObjectModel;
using System.Globalization;
using System.Linq;
using System.Net;
using System.Windows;
using System.Windows.Controls;
using System.Windows.Documents;
using System.Windows.Input;
using System.Windows.Media;
using System.Windows.Media.Animation;
using System.Windows.Shapes;
using SilverlightControlStyle.Controls;
using SilverlightControlStyle.Models;

namespace SilverlightControlStyle
{
    public partial class MainPage : UserControl
    {
        private readonly List<Fruit> _choices = Fruit.GetFruitChoices();

        public MainPage()
        {
            InitializeComponent();

            ObservableCollection<string> list = new ObservableCollection<string>();
            for (int i = 1; i <= 10; i++)
            {
                list.Add("Item" + i);
            }

            XComboBox.ItemsSource = list;
            XComboBox2.ItemsSource = list;

            XEditComboBox.ItemsSource = _choices;
            XEditComboBox.FilterMemberPath = "Name";
            XEditComboBox.SelectedItem = _choices[0];
            XEditComboBox2.ItemsSource = _choices;
            XEditComboBox2.FilterMemberPath = "Name";
            XEditComboBox2.SelectedItem = _choices[0];

            WaitTipEx.WaitMessage("Test1", "延时操作成组提示1...");
            WaitTipEx.WaitMessage("Test2", "延时操作成组提示2...");
            WaitTipEx.WaitMessage("Test3", "延时操作成组提示3...");
        }

        private void TextBox_MouseEnter(object sender, MouseEventArgs e)
        {
            if (sender is TextBox)
            {
                var txtBox = sender as TextBox;
                PopTipEx.PopTip(txtBox, "当前值：" + txtBox.Text);
            }
        }

        private void XComboBox_SelectionChanged(object sender, SelectionChangedEventArgs e)
        {
            if (sender is ComboBox)
            {
                var comBox = sender as ComboBox;
                PopTipEx.PopTip(comBox, "当前选择值：" + comBox.SelectedItem);
            }
        }

        private void NumericUpDown_ValueChanged(object sender, RoutedPropertyChangedEventArgs<double> e)
        {
            if (sender is NumericUpDown)
            {
                var numericUpDown = sender as NumericUpDown;
                PopTipEx.PopTip(numericUpDown, "当前值：" + numericUpDown.Value.ToString(CultureInfo.InvariantCulture));
            }
        }

    }
}
